package ObjectVC;

import java.util.ArrayList;
import java.util.Date;
import javax.swing.JOptionPane;

public aspect Control {
	after(Object actualObj, Action action, ArrayList<Object> actionParams): 
		VCOperations.VCops(actualObj, action, actionParams) 
		&& if(action.equals(Action.Control)){
		if (null != actionParams && actionParams.size()>0){
			Date timestamp = null;
			String comment = null;
			VCMode vcMode = null;
			
			Object obj = actionParams.get(0);
			if(actionParams.size() > 1) timestamp = (Date) actionParams.get(1);
			if(actionParams.size() > 2) comment = (String) actionParams.get(2);
			if(actionParams.size() > 3) vcMode = (VCMode) actionParams.get(3);
			DB.addToDB(obj, timestamp, comment, vcMode);
		}
		else
			JOptionPane.showMessageDialog(null, "Object is null");
	}
}
